package com.hospital.pharmacy.impl;

import com.alibaba.fastjson.JSON;
import com.hospital.pharmacy.dao.SuppilerMapper;
import com.hospital.pharmacy.entity.Suppiler;
import com.hospital.pharmacy.service.SuppilerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*
 * @program: Hospital
 * @description: 供应商
 * @author: 杨曼珍
 * @create: 2019-01-04 18:08
 */

@Service

public class SuppilerServiceImpl implements SuppilerService {
    @Autowired
    SuppilerMapper suppilerMapper;


    @Override
    public String getAllSuppiler(){
        List<Suppiler>suppilers=suppilerMapper.selectAllSuppiler();
        List<Map<String,String>>resaultmap=new ArrayList<>();
        Map<String,String>map;
        for (Suppiler suppiler:suppilers) {
            map = new HashMap<>();
            map.put("id",suppiler.getId().toString());
            map.put("sup_name",suppiler.getSupName());
            map.put("sup_contact_info",suppiler.getSupContactInfo());
            map.put("sup_address",suppiler.getSupAddress());
            map.put("sup_remark",suppiler.getSupRemark());
            resaultmap.add(map);
        }
        return JSON.toJSONString(resaultmap);
    }

}
